/**   
* @Title: PriceManagerController.java 
* @Package com.kerrykidz.scminvoicing.controller 
* @Description: 用一句话描述该文件做什么 
* Copyright: Copyright (c) 2014 
* Company:wuwh team by iss
* @author: ScreenJxp   
* @date: 2014年8月27日 上午10:05:49 
* @version: V1.0
* update Release(文件修正记录)
* <pre>
* author--updateDate--description----------------------Flag————
* wuwh    2014-5-1    测试codesyle                      #wuwh001
*
*
*
* </pre>
*
*/
package com.kerrykidz.scminvoicing.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.activiti.engine.runtime.ProcessInstance;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.kerrykidz.common.Constants;
import com.kerrykidz.common.PrimaryKeyGenerator;
import com.kerrykidz.common.PrimaryKeyGenerator.BusinessType;
import com.kerrykidz.common.service.ICommonService;
import com.kerrykidz.scminvoicing.dao.model.GblScmPrdCateEntity;
import com.kerrykidz.scminvoicing.dao.model.GblScmPrdEntity;
import com.kerrykidz.scminvoicing.dao.model.GblScmPrdPriceEntity;
import com.kerrykidz.scminvoicing.dao.model.ScmPrdPriceEntity;
import com.kerrykidz.scminvoicing.service.IPriceManagerService;
import com.kerrykidz.scminvoicing.service.IScmInvocingProductInfoService;
import com.kerrykidz.system.dao.model.GblSecBranEntity;
import com.kerrykidz.system.util.ConstantUtil;
import com.kerrykidz.system.util.DataSourceUtil;
import com.kerrykidz.system.util.ConstantUtil.WorkflowKey;
import com.kerrykidz.system.util.UserUtil;
import com.kerrykidz.system.vo.UserInfo;
import com.kerrykidz.workflow.service.IWorkflowService;
import com.kerrykidz.workflow.vo.WorkflowParamVo;
import com.rdp.framework.exception.RDPException;
import com.rdp.util.GenerationUUID;
import com.rdp.util.lang.StringUtil;
import com.rdp.util.time.DateFormatUtil;

@RequestMapping("scmInvocing/priceManager")
@Controller
public class PriceManagerController {
		//总部价格管理
		@Autowired
		private IPriceManagerService priceManagerService;
		
		@Autowired 
		private ICommonService commonService;
		//工作流
		@Autowired
		private IWorkflowService workflowService;
		//操作商品的service
		@Autowired 
		private IScmInvocingProductInfoService productService;
		@Autowired
		DataSourceUtil das;
		@RequestMapping("/forwardToList")
		public ModelAndView forwardToList() throws RDPException{
			ModelAndView mav=new  ModelAndView("invoicing/invo_pricemanage");
			UserInfo user=UserUtil.getUserFromSession();
			String abbrCode=user.getBranId();
			GblSecBranEntity bran=new GblSecBranEntity();
			List<GblSecBranEntity> branList=null;
			if(abbrCode!=null &&Constants.HEAD_OFFICE_CODE.equals(abbrCode)){
					 branList=commonService.getBranList(bran);
					 mav.addObject("headCode", abbrCode);
					abbrCode="1";	
			}else{
				 bran.setPkBranId(user.getBranId());
				branList=commonService.getBranList(bran);
				 mav.addObject("headCode", "");
				abbrCode="0";	
			}
			mav.addObject("branId", user.getBranId());
			mav.addObject("isHead", abbrCode);
			mav.addObject("fkBranId", user.getBranId());
			mav.addObject("branList",branList);
			return mav;
		}
		/**
		 * @throws RDPException 
		 * 
		*
		* @Title: getBranchInfo
		* @Description: <p>获取门店的定价信息<p>
		* <pre>
			这里描述这个方法的使用方法 – 可选
		* </pre>
		* @param: <p>@return<p>
		* @date: 2014年8月28日
		* @return: ScmPrdPriceEntity
		* @throws 
		*
		 */
		@RequestMapping("/getBranchInfo")
		@ResponseBody
		public ScmPrdPriceEntity getBranchInfo(ScmPrdPriceEntity entity) throws RDPException{
			UserInfo info=UserUtil.getUserFromSession();
			entity.setIspaging(true);
			entity.setCateId(entity.getCateId());
			String isBoss="0";
			String isManager="0";
			if(info.getRoleList()!=null&&info.getRoleList().size()>0){
					for(String id:info.getRoleList()){
						//判断是否为总监
							if(Constants.isBoss.equals(id)){
								isBoss="1";
							}
							if(Constants.isManager.equals(id)){
								isManager="1";
							}
					}
			}
			List<Object>  largeList=new ArrayList<Object>();
			List<GblScmPrdCateEntity> cateList=productService.recurseCate(entity.getCateId(), true, true);
			entity.setCateList(cateList);
			List<ScmPrdPriceEntity> resultList=priceManagerService.findPriceInfoForBranch(entity);
			largeList.add(resultList);
			largeList.add(isBoss);
			largeList.add(isManager);
			entity.setResults(largeList);
			return entity;
		}
		/**
		 * @throws RDPException 
		 * 
		*
		* @Title: getHeadInfo
		* @Description: <p>获取总部的所有定价信息<p>
		* <pre>
			这里描述这个方法的使用方法 – 可选
		* </pre>
		* @param: <p>@return<p>
		* @date: 2014年8月28日
		* @return: GblScmPrdPriceEntity
		* @throws 
		*
		 */
		@RequestMapping("/getHeadInfo")
		@ResponseBody
		public GblScmPrdPriceEntity getHeadInfo(GblScmPrdPriceEntity entity) throws RDPException{
				UserInfo info=UserUtil.getUserFromSession();
				String isBoss="0";
				//判断是否为总监
				if(info.getRoleList()!=null&&info.getRoleList().size()>0){
						for(String id:info.getRoleList()){
								if(Constants.isBoss.equals(id)){
									isBoss="1";
									break;
								}
						}
				}
				entity.setIspaging(true);
				entity.setIsBoss(isBoss);
				entity.setCateId(entity.getCateId());
				List<Object> arr=new ArrayList<Object>();
				List<GblScmPrdCateEntity> cateList=productService.recurseCate(entity.getCateId(), true, true);
				entity.setCateList(cateList);
				List<GblScmPrdPriceEntity> result=priceManagerService.findPriceInfoForHead(entity);
				arr.add(result);
				arr.add(isBoss);
				entity.setResults(arr);
				return entity;
		}
		/**
		 * 跳转到重新提交页面
		 * @param entity
		 * @return
		 * @throws RDPException
		 * @date: 2014年10月23日
		 */
		@RequestMapping("/forwardToReSubmitHead")
		public ModelAndView  forwardToReSubmitHead(GblScmPrdPriceEntity entity) throws RDPException{
			ModelAndView mav=new  ModelAndView("invoicing/invo_reSubmitForHead");
			List<GblScmPrdPriceEntity> list=priceManagerService.findPriceInfoForHead(entity);
			entity=list!=null&&list.size()>0?list.get(0):null;
			mav.addObject("entity", entity);
			mav.addObject("setName", entity.getUserName());
			String setDate=DateFormatUtil.convertDateToStr(entity.getValidFrom(), "yyyy-MM-dd");
			mav.addObject("setDate", setDate);
			return mav;
		}
		/**
		 * 编辑或重新定价页面
		 * @return
		 * @throws RDPException 
		 * @date: 2014年8月29日
		 */
		@RequestMapping("/forwardEditForHead")
		public ModelAndView forwardToResetPrice(GblScmPrdPriceEntity entity) throws RDPException{
			ModelAndView mav=new  ModelAndView("invoicing/invo_editPriceForHead");
			mav.addObject("isNew", entity.getIsNew());
			String isNew=entity.getIsNew();
			UserInfo user=UserUtil.getUserFromSession();
			List<GblScmPrdPriceEntity> list=priceManagerService.findPriceInfoForHead(entity);
			entity=list!=null&&list.size()>0?list.get(0):null;
			String nowDate="";
			String userName="";
			if("y".equals(isNew)){
				 nowDate=DateFormatUtil.convertDateToStr(new Date(), "yyyy-MM-dd");
				 userName=user.getName();
			}else{
				 nowDate=DateFormatUtil.convertDateToStr(entity.getValidFrom()!=null?entity.getValidFrom():new Date(), "yyyy-MM-dd");
				 userName=entity.getUserName();
			}
			mav.addObject("modiBy", user.getUserId());
			mav.addObject("userName", userName);
			mav.addObject("nowDate", nowDate);
			mav.addObject("entity", entity);
			return mav;
		}
		/**
		 * 跳转到定价页面和重新定价页面
		 * @return
		 * @throws RDPException 
		 * @date: 2014年8月29日
		 */
		@RequestMapping("/setPriceForHead")
		public ModelAndView setPriceForHead(GblScmPrdPriceEntity entity) throws RDPException{
			UserInfo user=UserUtil.getUserFromSession();
			String nowDate=DateFormatUtil.convertDateToStr(new Date(), "yyyy-MM-dd");
			ModelAndView mav=new  ModelAndView("invoicing/invo_setPriceForHead");
			List<GblScmPrdPriceEntity> list=priceManagerService.findPriceInfoForHead(entity);
			entity=list!=null&&list.size()>0?list.get(0):null;
			mav.addObject("modiBy", user.getUserId());
			mav.addObject("userName", user.getName());
			mav.addObject("nowDate", nowDate);
			mav.addObject("entity", entity);
			return mav;
		}
		/**
		 *保存总部定价的信息
		 * @return
		 * @throws RDPException 
		 * @date: 2014年9月1日
		 */
		@RequestMapping("/saveSetPriceForHead")
		@ResponseBody
		public String saveSetPriceForHead(GblScmPrdPriceEntity entity) throws RDPException{
			//修改商品是否允许分店定价的标示
			GblScmPrdEntity prdEnitity=new GblScmPrdEntity();
			prdEnitity.setBrancePrice(entity.getIsAllow());
			prdEnitity.setPkPrdId(entity.getFkPrdId());
			productService.updateProduct(prdEnitity);
			entity.setPkPriceId(GenerationUUID.getGenerationUUID());
			priceManagerService.savePriceForHead(entity);
			return "success";
		}
		/**
		 * 修改价格或者保存重新定价
		 * @param entity
		 * @return
		 * @throws RDPException
		 * @date: 2014年9月4日
		 */
		@RequestMapping("/updatePriceForHead")
		@ResponseBody
		public String updatePriceForHead(GblScmPrdPriceEntity entity) throws RDPException{
			GblScmPrdEntity prdEnitity=new GblScmPrdEntity();
			prdEnitity.setBrancePrice(entity.getIsAllow());
			prdEnitity.setPkPrdId(entity.getFkPrdId());
			String isNew=entity.getIsNew();
			productService.updateProduct(prdEnitity);
			if("n".equals(isNew)){//update
				priceManagerService.updatePriceForHead(entity);
			}else{//重新定价 update and insert
				String pkPriceId=GenerationUUID.getGenerationUUID();
				entity.setPkPriceId(pkPriceId);
				priceManagerService.savePriceForHead(entity);
			}
			return "success";
		}
		/**
		 * @throws RDPException 
		 * 
		*
		* @Title: forwardToHandPrice
		* @Description: <p>总部定价审核<p>
		* <pre>
			这里描述这个方法的使用方法 – 可选
		* </pre>
		* @param: <p>@return<p>
		* @date: 2014年8月28日
		* @return: ModelAndView
		* @throws 
		*
		 */
		@RequestMapping("/reviewPriceForHead")
		public ModelAndView forwardToHandPrice(GblScmPrdPriceEntity entity) throws RDPException{
			ModelAndView mav=new  ModelAndView("invoicing/invo_reviewPriceForHead");
			UserInfo user=UserUtil.getUserFromSession();
			List<GblScmPrdPriceEntity> list=priceManagerService.findPriceInfoForHead(entity);
			entity=list!=null&&list.size()>0?list.get(0):null;
			String nowDate=DateFormatUtil.convertDateToStr(entity.getValidFrom()!=null?entity.getValidFrom():new Date(), "yyyy-MM-dd");
			mav.addObject("modiBy", user.getUserId());
			mav.addObject("userName", entity.getUserName());
			mav.addObject("nowDate", nowDate);
			mav.addObject("entity", entity);
			return mav;
		}
		/**
		 * 总部复核员执行价格复核操作，审批操作
		 * @param entity
		 * @return
		 * @throws RDPException 
		 * @date: 2014年9月1日
		 */
		@RequestMapping("/checkHeadPrice")
		@ResponseBody
		public String checkHeadPrice(GblScmPrdPriceEntity entity) throws RDPException{
			UserInfo user=UserUtil.getUserFromSession();
			//同意定价，删除上一次生效的数据
			if("1".equals(entity.getStatus())){
				GblScmPrdPriceEntity priceEntity=new GblScmPrdPriceEntity();
				priceEntity.setModiBy(user.getUserId());
				priceEntity.setFkPrdId(entity.getFkPrdId());
				priceManagerService.createHistoryData(priceEntity);
			}
			entity.setModiBy(user.getUserId());
			priceManagerService.updatePriceForHead(entity);
			return "success";
		}
		/**
		 * 根据指定条件查询商品分类信息
		 * @param entity
		 * @return
		 * @throws RDPException
		 * @date: 2014年8月29日
		 */
		@RequestMapping("/findCategoryList")
		@ResponseBody
		public List<GblScmPrdCateEntity> findCategoryList(GblScmPrdCateEntity entity) throws RDPException{
			entity.setDelFlag("0");
			List<GblScmPrdCateEntity> resultList= productService.findCategoryList(entity);
			return resultList;
		}
		/**
		 * 重新设置定价或重新定价,会产生历史
		 * @param entity
		 * @return
		 * @throws RDPException
		 * @date: 2014年9月1日
		 */
		@RequestMapping("/reSetPriceForHead")
		@ResponseBody
		public String reSetPriceForHead(GblScmPrdPriceEntity entity) throws RDPException{
			GblScmPrdEntity prdEnitity=new GblScmPrdEntity();
			prdEnitity.setBrancePrice(entity.getIsAllow());
			prdEnitity.setPkPrdId(entity.getFkPrdId());
			productService.updateProduct(prdEnitity);//修改商品的是否允许定价状态
			priceManagerService.updatePriceForHead(entity);
			return "success";
		}
		/**
		 * 获取总部的定价历史信息
		 * @param entity
		 * @return
		 * @throws RDPException
		 * @date: 2014年10月23日
		 */
		@RequestMapping("/findHistoryForHead")
		@ResponseBody
		public  GblScmPrdPriceEntity  findHistoryForHead(GblScmPrdPriceEntity entity) throws RDPException{
					entity.setIspaging(true);
					List<GblScmPrdPriceEntity> resultList=priceManagerService.findHistoryForHead(entity.getFkPrdId());
					entity.setResults(resultList);
					return entity;
		}
		/**
		 * 
		 * @param session
		 * @param entity
		 * @param isReset 是否重置
		 * @param branchPrice 门店价格
		 * @return
		 * @throws RDPException
		 * @date: 2014年9月30日
		 */
		@RequestMapping("/setPriceForBranch")
		public ModelAndView setPriceForBranch(ScmPrdPriceEntity entity,String isReset,Double branchPrice) throws RDPException{
			ModelAndView mav=new ModelAndView("invoicing/invo_setPriceForBranch");
			UserInfo user=UserUtil.getUserFromSession();
			String nowDate=DateFormatUtil.convertDateToStr(new Date(), "yyyy-MM-dd");
			mav.addObject("branId", entity.getFkBranId());
			List<ScmPrdPriceEntity> list=priceManagerService.findPriceInfoForBranch(entity);
			entity=list!=null&&list.size()>0?list.get(0):null;
			mav.addObject("userId",user.getUserId());
			mav.addObject("userName",user.getName());
			mav.addObject("branName", user.getBranName());
			mav.addObject("nowDate", nowDate);
			mav.addObject("branchPrice",branchPrice);
			mav.addObject("isReset", isReset!=null?isReset:"");
			mav.addObject("entity", entity);
			return mav;
		}
		/**
		 * 
		 * @param entity
		 * @param session
		 * @param isReset 是否为重新定价
		 * @return
		 * @throws RDPException
		 * @date: 2014年9月12日
		 */
		@RequestMapping("/savePriceForBranch")
		@ResponseBody
		public String savePriceForBranch(ScmPrdPriceEntity entity,String isReset) throws RDPException{
					UserInfo user=UserUtil.getUserFromSession();
					entity.setApplyBy(user.getUserId());
					entity.setModiBy(user.getUserId());
					String pkPriceId=PrimaryKeyGenerator.getPrimaryKey(BusinessType.DJ, user.getAbbrCode());
					entity.setPkPriceId(pkPriceId);
					entity.setFkBranId(user.getBranId());
					//提交到总部走流程.
					if("2".equals(entity.getStatus())){
						priceManagerService.savePriceForBranch(entity);
						String   flowId= workflowService.startWorkflow(ConstantUtil.getWorkflowKey(WorkflowKey.price), entity.getPkPriceId(), user);
						entity.setFkFlowinstId(flowId);
						 if(StringUtil.isNotBlank(flowId)){
							 entity.setStatus("2");
							 	priceManagerService.updatePriceForBranch(entity);
								//如果是门店的话就进行数据上传
								if(user.getBranId().indexOf("ZB") == -1){
									 ScmPrdPriceEntity price=priceManagerService.findPriceForBranchById(entity.getPkPriceId(), "");
									das.executePrice(price, "insert");
								}
							}
					}else{
						priceManagerService.savePriceForBranch(entity);
					}
					return "success";
		}
		@RequestMapping("/updatePriceForBranchPage")
		public ModelAndView  updatePriceForBranchPage(ScmPrdPriceEntity entity) throws RDPException{
			UserInfo info=UserUtil.getUserFromSession();
			ModelAndView mav=new ModelAndView("invoicing/invo_updatePriceForBranch");
			mav.addObject("entity",priceManagerService.findPriceForBranchById(entity.getPkPriceId(),info.getUserId()));
			return mav;
		}
		@RequestMapping("/updatePriceForBranch")
		@ResponseBody
		public String updatePriceForBranch(ScmPrdPriceEntity entity) throws RDPException{
			UserInfo user=UserUtil.getUserFromSession();
			//提交到总部
			if("2".equals(entity.getStatus())){
				String   flowId= workflowService.startWorkflow(ConstantUtil.getWorkflowKey(WorkflowKey.price), entity.getPkPriceId(), user);
				if(StringUtils.isNotBlank(flowId)){
					entity.setFkFlowinstId(flowId);
					priceManagerService.updatePriceForBranch(entity);
					 if(StringUtil.isNotBlank(user.getBranId())){
							//如果是门店的话就进行数据上传
							if(user.getBranId().indexOf("ZB") == -1){
								 ScmPrdPriceEntity price=priceManagerService.findPriceForBranchById(entity.getPkPriceId(), "");
								das.executePrice(price, "insert");
							}
						}
				}
			}else{
				priceManagerService.updatePriceForBranch(entity);
			}
			return "success";
		}
		/**
		 * 总监审批门店的定价审批
		 * @param entity
		 * @param session
		 * @return
		 * @throws RDPException
		 * @date: 2014年9月10日
		 */
		@RequestMapping("/handPriceForBranchPage")
		public ModelAndView  handPriceForBranchPage(ScmPrdPriceEntity entity) throws RDPException{
			UserInfo info=UserUtil.getUserFromSession();
			ModelAndView mav=new ModelAndView("invoicing/invo_handlePriceForBranch");
			entity=priceManagerService.findPriceForBranchById(entity.getPkPriceId(),info.getUserId());
			String nowDate=DateFormatUtil.convertDateToStr(entity.getApplyTime()!=null?entity.getApplyTime():new Date(), "yyyy-MM-dd");
			mav.addObject("entity",entity);
			mav.addObject("nowData", nowDate);
			return mav;
		}
		@RequestMapping("/reSubmitForBranchPage")
		public ModelAndView  reSubmitForBranchPage(ScmPrdPriceEntity entity) throws RDPException{
			UserInfo info=UserUtil.getUserFromSession();
			ModelAndView mav=new ModelAndView("invoicing/invo_reSubmitForBranch");
			mav.addObject("fkFlowinstId", entity.getFkFlowinstId());
			entity=priceManagerService.findPriceForBranchById(entity.getPkPriceId(),info.getUserId());
			mav.addObject("entity",entity);
			return mav;
		}
		@RequestMapping("/handResubmitForBranch")
		@ResponseBody
		public String handResubmitForBranch(ScmPrdPriceEntity entity) throws RDPException{
			UserInfo info=UserUtil.getUserFromSession();
			if("2".equals(entity.getStatus())){
				WorkflowParamVo workflowparam=new WorkflowParamVo();
				workflowparam.setUserInfo(info);
				workflowparam.setProcessInstanceId(entity.getFkFlowinstId());
				workflowparam.setHandleAdviceDes(ConstantUtil.WORKFLOW_STATUS_REAPPLY);
				ProcessInstance instance=	workflowService.complete(workflowparam);
				if(instance!=null){
					priceManagerService.updatePriceForBranch(entity);
					 if(StringUtil.isNotBlank(info.getBranId())){
							//如果是门店的话就进行数据上传
							if(info.getBranId().indexOf("ZB") == -1){
								 ScmPrdPriceEntity price=priceManagerService.findPriceForBranchById(entity.getPkPriceId(), "");
								das.executePrice(price, "update");
							}
					 }
				}
			}
			else{
					priceManagerService.updatePriceForBranch(entity);
			}	
			return Constants.SUCCESS;
		}
		/**
		 * 总监执行定价审批
		 * @param entity
		 * @param session
		 * @return
		 * @throws RDPException
		 * @date: 2014年9月10日
		 */
		@RequestMapping("/handPriceForBranch")
		@ResponseBody
		public String  handPriceForBranch(ScmPrdPriceEntity entity) throws RDPException{
			UserInfo user=UserUtil.getUserFromSession();
			String status=entity.getCateId();
			String fkFlowinstId=entity.getFkFlowinstId();
			String comments=entity.getCateName();
			ScmPrdPriceEntity price=new ScmPrdPriceEntity();
			price.setStatus(status);
			price.setFkFlowinstId(fkFlowinstId);
			price.setPkPriceId(entity.getPkPriceId());
			String handleAdviceDes="";
			if("3".equals(status)){
				handleAdviceDes="同意";
			}else if("4".equals(status)){
				handleAdviceDes="不同意";
			}else{
				handleAdviceDes="不同意";
			}
			WorkflowParamVo workflowparam=new WorkflowParamVo();
			workflowparam.setHandleAdviceDes(handleAdviceDes);
			workflowparam.setProcessInstanceId(fkFlowinstId);
			workflowparam.setHandleReason(comments);
			workflowparam.setUserInfo(user);
			if("5".equals(status)){
				//退回流程
				price.setStatus("2");
				workflowService.backProcessToStart(workflowparam);
				priceManagerService.updatePriceForBranch(price);
			}else{
				ProcessInstance instance=	workflowService.complete(workflowparam);
				if(instance==null){
					if("3".equals(status)){//删除已经生效的数据
						priceManagerService.deleteOldPrice(entity.getFkPrdId(),user.getBranId());
					}
					priceManagerService.updatePriceForBranch(price);
				}
			}
			return Constants.SUCCESS;
		}
		@ResponseBody
		@RequestMapping("/findHistoryForBranch")
		public ScmPrdPriceEntity findHistoryForBranch(ScmPrdPriceEntity entity) throws RDPException{
			entity.setIspaging( true);
			entity.setResults(priceManagerService.findHistoryForBranch(entity));
			return entity;
		}
		/**
		 * 删除草稿状态的定价信息
		 * @param pkPriceId
		 * @return
		 * @throws RDPException
		 * @date: 2014年9月29日
		 */
		@RequestMapping("/deleteTempPrice")
		public String deleteTempPrice(@RequestParam("pkPriceId")String pkPriceId) throws RDPException{
			priceManagerService.deleteTempPrice(pkPriceId);
			 return "redirect:/scmInvocing/priceManager/forwardToList.shtml";
		}
		/**
		 * 查看门店的基本信息
		 * @return
		 * @throws RDPException 
		 * @date: 2014年10月11日
		 */
		@RequestMapping("/readBranchInfo")
		public ModelAndView readBranchInfo(ScmPrdPriceEntity entity) throws RDPException{
			UserInfo info=UserUtil.getUserFromSession();
			ModelAndView mav=new ModelAndView("invoicing/invo_readBranchInfo");
			//未定价数据
			if("".equals(entity.getPkPriceId())){
				entity.setFkBranId(info.getBranId());
				GblScmPrdPriceEntity gbl=new GblScmPrdPriceEntity();
				List<GblScmPrdPriceEntity> list=priceManagerService.findPriceInfoForHead(gbl);
				gbl=list!=null&&list.size()>0?list.get(0):null;
				gbl.setBranName("上海总部");
				gbl.setOrderTime(gbl.getValidFrom()!=null?DateFormatUtil.convertDateToStr(gbl.getValidFrom(), "yyyy-MM-dd"):DateFormatUtil.convertDateToStr(new Date(), "yyyy-MM-dd"));
				mav.addObject("entity",gbl);
			}else{
				mav.addObject("entity",priceManagerService.findPriceForBranchById(entity.getPkPriceId(),info.getUserId()));
			}
			return mav;
		}
		/**
		 * 查看门店流程中的详细数据...
		 * @return
		 * @date: 2014年10月11日
		 */
		@RequestMapping("/readBranchOnFlow")
		public ModelAndView readBranchOnFlow(){
				ModelAndView mav=new ModelAndView("");
				return mav;
		}
		/**
		 * 查询总部的中商品的基本信息 
		 * @return
		 * @throws RDPException 
		 * @date: 2014年10月11日
		 */
		@RequestMapping("/readHeadInfo")
		public ModelAndView readHeadInfo(GblScmPrdPriceEntity entity) throws RDPException{
			ModelAndView mav=new  ModelAndView("invoicing/invo_readHeadInfo");
			UserInfo user=UserUtil.getUserFromSession();
			List<GblScmPrdPriceEntity> list=priceManagerService.findPriceInfoForHead(entity);
			entity=list!=null&&list.size()>0?list.get(0):null;
			String nowDate=DateFormatUtil.convertDateToStr(entity.getValidFrom()!=null?entity.getValidFrom():new Date(), "yyyy-MM-dd");
			mav.addObject("modiBy", user.getUserId());
			mav.addObject("userName", entity.getUserName());
			mav.addObject("nowDate", nowDate);
			mav.addObject("entity", entity);
			return mav;
		}
		
		
}
